export {};

class Person {
  public name: string;
  private age: number; //私有
  protected readonly gender: boolean; //受保护,只允许在子类中访问 如果已经有了访问修饰符，则readonly应该跟在后面
  constructor(name: string, age: number) {
    this.name = name;
    this.age = age;
    this.gender = true;
  }
  say(msg: string): void {
    console.log(`i am ${this.name}, ${msg}`);
    console.log(this.age);
  }
}
class Student extends Person {
  private constructor(nama: string, age: number) {
    //private 也不可被访问 只可在类里创建静态方法，在静态方法中创建实例 protected之后也不可被外部使用 但可以被继承
    super(name, age);
    console.log(this.gender);
  }
  static create(name: string, age: number) {
    return new Student(name, age);
  }
}
const tom = new Person("tom", 10);
// console.log(tom.age);
// console.log(tom.gender);
